#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/wait.h>
int main()
{
	pid_t id = fork();//创建子进程；
	if(id == 0)
	{
		int cnt = 5;
		while(cnt)
		{
			printf("child procese:pid = %d cnt = %d\n",getpid(),cnt--);
			sleep(1);
		}
		exit(10);
	}
	else
	{
		int cnt = 10;
		while(cnt)
		{
			printf("parent procese pid = %d  cnt = %d\n",getpid(),cnt--);
			sleep(1);
		}
		int status = 0;
		pid_t ret = wait(&status);
		if(ret == id)
		{
			printf("等待成功,eixtsignal:%d  ,exit_code : %d\n",0x7f&status,(status>>8)&0xff);
		}
	}
	sleep(10);
	return 0;
}
